package s_001_Bean_Registered.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import s_001_Bean_Registered.bean.Person;
import s_001_Bean_Registered.bean.Tmp;

@Configuration // 告诉 Spring 这是一个配置类
@ComponentScan // 默认扫描当前包(com.test.config)及其子包(com.test.config.*)
public class MainConfig {

    // 给容器中注册一个 Bean，类型为返回值的类型，id 默认是用方法名作为 id
    // @Bean("person123")
    public Person person() {
        return new Person("lisi", 20, "nice");
    }

    @Bean
    @Scope("singleton")
    public Tmp tmp() {
        return new Tmp();
    }
}